package com.jvup.common.constant;

/**
 * 自定义通知事件标签资源管理
 */
public class CustomEvent {

    /** 登陆成功 */
    public static final String LOGIN_SUCCESS    = MessageIdGenerator.generator.createToString();
    /** 登录刷新 */
    public static final String LOGIN_REFRESH    = MessageIdGenerator.generator.createToString();

    /** 弹幕编辑完成并发送 */
    public static final String BULLET_SCREEN_EDIT_SEND    = MessageIdGenerator.generator.createToString();

    /** 弹幕编辑取消 */
    public static final String BULLET_SCREEN_EDIT_CANCEL  = MessageIdGenerator.generator.createToString();

    /** 评论提交成功 */
    public static final String COMMENT_SUBMIT_SUCCESS  = MessageIdGenerator.generator.createToString();


    protected final static class MessageIdGenerator {

        protected static final MessageIdGenerator generator = new MessageIdGenerator();

        private volatile int baseId = 1;

        private MessageIdGenerator() {}

        /**
         * @return 生成唯一ID
         */
        public synchronized int create() {
            return baseId++;
        }

        /**
         * @return 生成唯一ID并且转换成String
         */
        public String createToString() {
            return String.valueOf(create());
        }
    }

}
